﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LWrap.IndexSync
{
    public class FileSynchonizer
    {
        public IndexFileSyncBase FileSyncAgent { get; set; }
        public string SourceIndexPath { get; set; }
        public string DestinationIndexPath { get; set; }

        public FileSynchonizer() { }
        public FileSynchonizer(IndexFileSyncBase fileSyncAgent, string sourceIndexPath, string destinationIndexPath)
        {
            this.FileSyncAgent = fileSyncAgent;
            this.DestinationIndexPath = destinationIndexPath;
            this.SourceIndexPath = sourceIndexPath;
        }

        public void InitiateSyncProcess()
        {
            if (FileSyncAgent == null)
                throw new NullReferenceException("FileSyncAgent is null");
            if(string.IsNullOrEmpty(this.SourceIndexPath)==true)
                throw new NullReferenceException("SourceIndexPath is null");
            if (string.IsNullOrEmpty(this.DestinationIndexPath) == true)
                throw new NullReferenceException("DestinationIndexPath is null");

            FileSyncAgent.SyncFiles(this.SourceIndexPath, this.DestinationIndexPath);
        }

    }
}
